package mytest.ssw.www.myandroidproject.AnalysisJson;

import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import mytest.ssw.www.myandroidproject.mydate.CheckUpdateInfo;
import mytest.ssw.www.myandroidproject.mydate.Userinfo;

/**
 * Created by 73409 on 2015/10/25.
 */
public class AnalysisJ {

    public Userinfo rejister_analysis(String JsonStr)
    {
        Userinfo userinfo = new Userinfo();
        try {
            JSONObject   jsonObject = new JSONObject(JsonStr);

             for (int i =0;i<jsonObject.length();i++)
             {
                 userinfo.setUid(jsonObject.getString("uid"));
                 userinfo.setUname(jsonObject.getString("uname"));
                 userinfo.setUphone(jsonObject.getString("uphone"));
                 userinfo.setUsex(jsonObject.getString("usex"));
              }
        } catch (JSONException e) {
            e.printStackTrace();
        }

           return  userinfo;
    }

    public CheckUpdateInfo AnalysisCheckUpdate(String jsonstr)
    {
        Log.v("jsonstr",jsonstr);
        CheckUpdateInfo checkUpdateInfo =new CheckUpdateInfo();
        try {
            JSONObject jsonObject = new JSONObject(jsonstr);
            checkUpdateInfo.setApkurl("http://116.55.250.17/dd.myapp.com/16891/1E809BD887623D9EC59B2D4068BAFC58.apk?mkey=562f5c7106718529&f=8f5d&fsname=longbin.helloworld_3.4.0_32.apk&asr=02f1&p=.apk");
            checkUpdateInfo.setDescription(jsonObject.getString("description"));
            checkUpdateInfo.setVersion(jsonObject.getString("version"));
        } catch (JSONException e) {
            e.printStackTrace();
            Log.v("error", "json解析出错");
            checkUpdateInfo=null;
        }
        return checkUpdateInfo;
    }

}
